<template>
	<view class="page-main">
		<next-indexed-xlist v-if="show"  :dataList="list" :showAvatar="true" @itemclick="itemclick">
		</next-indexed-xlist>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				show:false
			}
		},
		onShow() {
			let that = this
			setTimeout(()=>{
				that.getlist()
			},500)
		},
		methods: {
			getlist(){
				uni.$TUIKit.getFriendList().then(res=>{
					this.list = res.data.map(item=>{
						return{
							id:item.userID,
							name:item.profile.nick,
							phone:item.userID,
							img:item.profile.avatar,
						}
					})
					this.show = true
				})
			},
			itemclick(e) {
				console.log(e);
				uni.navigateTo({
					url: `/pages/index/userinfo?userinfo=` + encodeURIComponent(JSON.stringify(e))
				})
			}
		}
	}
</script>

<style>

</style>